package com.xfatm.util.typecase;

import java.math.BigDecimal;

public class ToLongTypeCase {
    public class ObjectToLong implements TypeCase{
        @Override
        public Long typeCase(Object o) {
            if(o==null){
                return null;
            }
            return Long.parseLong(o.toString());
        }
    }

    public class ObjectToBaseLong implements TypeCase{
        @Override
        public Long typeCase(Object o) {
            if(o==null){
                return 0L;
            }
            return Long.parseLong(o.toString());
        }
    }

    public class BigDecimalToLong implements TypeCase{
        @Override
        public Long typeCase(Object o) {
            if(o==null){
                return null;
            }
            return ((BigDecimal)o).longValue();
        }
    }

    public class BigDecimalToBaseLong implements TypeCase{
        @Override
        public Long typeCase(Object o) {
            if(o==null){
                return 0L;
            }
            return ((BigDecimal)o).longValue();
        }
    }
}
